package one;

import java.util.List;
import java.util.ArrayList;

public class Twelvehundred {

    // 1237. 找出给定方程的正整数解
    public List<List<Integer>> findSolution(CustomFunction customfunction, int z) {
        ArrayList<List<Integer>> results = new ArrayList<>();
        for (int x = 1; x <= 1000; x++) {
            // 因为单调递增，所以
            int start = 1, end = 1000;
            do {
                int y = (start + end) / 2;
                if (customfunction.f(x, y) == z) {
                    ArrayList<Integer> result = new ArrayList<>();
                    result.add(x);
                    result.add(y);
                    results.add(result);
                    break;
                }
                if (customfunction.f(x, y) > z) {
                    end = y - 1;
                } else {
                    start = y + 1;
                }
            } while (end >= start);
        }
        return results;
    }

    class CustomFunction {
        public int f(int x, int y) {
            return 0;
        }
    }

}
